﻿using Jayrock.Json;
using open_api_sdk_csharp.com.chinaums.open.api.annotation;
/**
返回报文对象转换、发送请求检查
**/
namespace open_api_sdk_csharp.com.chinaums.open.api.internals.utils.convertors
{

    public class ObjectJsonParser<T> : OpenApiParser<T> where T : OpenApiResponse
    {
        public T parse(string paramString)
        {
            JsonConverter<T> converter = new JsonConverter<T>();
            return converter.toResponse(paramString, typeof(T));
        }

        public string validRequest(OpenApiRequest<T> openApiRequest)
        {
            OpenModelParser openModelParser = new OpenModelParser();
            JsonObject jsonObject = openModelParser.serializeRequestObject(openApiRequest);
            var attribute = openApiRequest.GetType().GetCustomAttributes(typeof(ApiField), true);
            return jsonObject.ToString();
        }
    }
}
